Skip to content

fix(proxy): crash on streaming — Buffer/String + [DONE] ordering - #2

Closed
tbosancheros39 wants to merge 1 commit into
masterfrom
fix/streaming-crashes
Closed

fix(proxy): crash on streaming — Buffer/String + [DONE] ordering#2
tbosancheros39 wants to merge 1 commit into
masterfrom
fix/streaming-crashes

Conversation

@tbosancheros39

Copy link
Copy Markdown
Owner

What

Two crash bugs in proxy.js confirmed by 3 independent reviews. Both crash the proxy on the first streaming chat request.

Bug 1 — chunk.charCodeAt is not a function

eventsource-parser.feed() expects string but Node.js HTTP data event delivers Buffer. Fix: typeof chunk === "string" ? chunk : chunk.toString("utf8")

Bug 2 — [DONE] is not valid JSON

JSON.parse(event.data) ran before the [DONE] guard. Fix: reorder — check [DONE] first, then parse.

Testing

  • deepseek-v4-flash via proxy: ✅
  • kimi-k2.7-code via OpenCode Go: ✅
  • kimi-k2.6 via OpenCode Go: ✅

Reviews

3 independent code reviews: all CORRECT. No side effects.

Closes #1

Bug 1: eventsource-parser.feed() expected string but HTTP data event
delivered Buffer. Convert chunk to string before parsing.

Bug 2: finish_reason JSON.parse ran before [DONE] guard check.
Move [DONE] guard above the JSON.parse call.

Both crash the proxy on the first streaming chat request.
Fixes #1
@tbosancheros39

Copy link
Copy Markdown
Owner Author

Closed after the repository history cleanup; the rewritten fix/streaming-crashes branch remains available.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

proxy.js crashes: Buffer/String mismatch + [DONE] JSON.parse ordering

1 participant